import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  // 一级路由
  {
    path: '/login',
    component: () => import('@/views/Login'),
  },
  {
    path: '/',
    // 重定向
    redirect: '/login',
    component: () => import('@/views/Home'),
    children: [
      {
        // 经常性错误 箭头函数()=>{return import('@/views/Home/Dashboard')}  忘记加return--要简写!!!!!!!!!

        path: 'dashboard',
        component: () => import('@/views/Home/Dashboard'),
      },
      {
        path: 'user',
        component: () => import('@/views/Home/User'),
      },
      {
        path: 'user/add',
        component: () => import('@/views/Home/User/UserAdd'),
      },
      {
        path: 'category',
        component: () => import('@/views/Home/Category'),
      },
      {
        path: 'manage',
        component: () => import('@/views/Home/Manage'),
      },
      {
        path: 'post',
        component: () => import('@/views/Home/Post'),
      },
      {
        path: 'addpost',
        component: () => import('@/views/Home/Post/addPost'),
      },
      {
        path: 'editpost',
        component: () => import('@/views/Home/Post/editPost'),
      },
    ],
  },
  {
    path: '*',
    component: () => import('@/views/404'),
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,
})

export default router
